from .. import db
from datetime import datetime


class Tool(db.Model):
    __tablename__ = "tools"
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(64), unique=True)
    other_files = db.Column(db.String(64))
    versions = db.relationship("Version", backref='tool', lazy="dynamic")
    description = db.Column(db.String(512))
    path = db.Column(db.String(64))

    def __eq__(self, other):
        try:
            assert self.other_files == other.other_files
            assert self.description == other.description
            assert self.latest == other.latest
            assert self.versions == other.versions
            return True
        except AssertionError:
            return False
